<template>
  <div class="chart" ref="chartRef"></div>
</template>

<script lang="ts">
export default {
  name: "BarChart",
};
</script>

<script lang="ts" setup>
import * as echarts from "echarts";
import { onMounted, ref } from "vue";

const chartRef = ref();

onMounted(() => {
  const myEcharts = echarts.init(chartRef.value);
  const option = {
    xAxis: {
      data: [
        "00:00",
        "01:00",
        "02:00",
        "03:00",
        "04:00",
        "05:00",
        "06:00",
        "07:00",
        "08:00",
        "09:00",
        "10:00",
        "11:00",
        "12:00",
        "13:00",
      ],
    },
    yAxis: {
      show: false,
    },
    grid: {
      top: 0,
      bottom: 0,
      left: -5,
      right: -5,
    },
    tooltip: {
      trigger: "axis",
    },
    series: {
      name: "实时交易量",
      type: "bar",
      data: [26, 5, 18, 26, 20, 16, 3, 18, 6, 20, 24, 19, 26, 20],
      // 图形样式
      itemStyle: {
        color: "#3398db", // 颜色
      },
      // 柱条宽度
      barWidth: 10,
    },
  };
  myEcharts.setOption(option);
});
</script>

<style scoped>
.chart {
  width: 100%;
  height: 100%;
}
</style>
